package com.zzyk.web.controller;

import com.zzyk.main.configuration.jwt.JwtToken;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author wss_PC
 * @DESCRIPTION 页面控制器
 * @create 2020/8/17 17:42
 */
@Controller
@RequestMapping("/pages")
public class PageController {

    @RequestMapping("/")
    public String IndexView() {
        return "index";
    }

    @RequestMapping("/index")
    public String pageIndexView(String token) {
        Subject subject = SecurityUtils.getSubject();
        if (!subject.isAuthenticated()) {
            JwtToken jwtToken = new JwtToken(token);
            subject.login(jwtToken);
            boolean permitted = subject.isPermitted("index:map");
            System.out.println("permitted = " + permitted);
        }
        return "pages/index";
    }

    /*    @RequiresPermissions("index:map")*/
    @RequestMapping("/gis")
    public String pageGisView() {
        return "pages/gis";
    }

    @RequiresPermissions("index:deviceList")
    @RequestMapping("/deviceList")
    public String pageDeviceListView() {
        return "pages/deviceList";
    }

    @RequiresPermissions("history:warn")
    @RequestMapping("/alarm")
    public String pageAlarmView() {
        return "pages/alarm";
    }

    @RequiresPermissions("history:data")
    @RequestMapping("/historyData")
    public String pageHistoryDataView() {
        return "pages/historyData";
    }

    @RequiresPermissions("history:record")
    @RequestMapping("/messageLog")
    public String pageMessageLogView() {
        return "pages/messageLog";
    }

    @RequiresPermissions(value = {"device:proc:view", "device:proc:opera"}, logical = Logical.OR)
    @RequestMapping("/prdEquManagement")
    public String pagePrdEquManagementView() {
        return "pages/prdEquManagement";
    }

    @RequiresPermissions(value = {"device:sensor:view", "device:sensor:opera"}, logical = Logical.OR)
    @RequestMapping("/acqEquManagement")
    public String pageAcqEquManagementView() {
        return "pages/acqEquManagement";
    }

    @RequiresPermissions(value = {"device:proc:maintenance:view", "device:proc:maintenance:opera"}, logical = Logical.OR)
    @RequestMapping("/prdEquMaintenance")
    public String pagePrdEquMaintenanceView() {
        return "pages/prdEquMaintenance";
    }

    @RequiresPermissions(value = {"device:sensor:maintenance:view", "device:sensor:maintenance:opera"}, logical = Logical.OR)
    @RequestMapping("/acqEquMaintenance")
    public String pageAcqEquMaintenanceView() {
        return "pages/acqEquMaintenance";
    }

    @RequiresPermissions(value = {"enterprise:info:view", "enterprise:info:opera"}, logical = Logical.OR)
    @RequestMapping("/companyManagement")
    public String pageCompanyManagementView() {
        return "pages/companyManagement";
    }

    @RequiresPermissions(value = {"enterprise:time:view", "enterprise:time:opera"}, logical = Logical.OR)
    @RequestMapping("/timeManagement")
    public String pageTimeManagementView() {
        return "pages/timeManagement";
    }

    @RequiresPermissions(value = {"bank:info:view", "bank:info:opera"}, logical = Logical.OR)
    @RequestMapping("/bankInfoManagement")
    public String pageBankInfoManagementView() {
        return "pages/bankInfoManagement";
    }

    @RequiresPermissions(value = {"bank:inner:view", "bank:inner:opera"}, logical = Logical.OR)
    @RequestMapping("/bankInternalManagement")
    public String pageBankInternalManagementView() {

        return "pages/bankInternalManagement";
    }

    @RequiresPermissions(value = {"sys:user:view", "sys:user:opera"}, logical = Logical.OR)
    @RequestMapping("/roleManagement")
    public String pageRoleManagementView() {
        return "pages/roleManagement";
    }

    @RequiresPermissions(value = {"sys:role:view", "sys:role:opera"}, logical = Logical.OR)
    @RequestMapping("/usersManagement")
    public String pageUsersManagementView() {
        return "pages/usersManagement";
    }

    @RequiresPermissions(value = {"system", "system:log"}, logical = Logical.OR)
    @RequestMapping("/systemLog")
    public String pageSystemLog() {
        return "pages/optionLog";
    }

    @RequiresPermissions(value = {"sys:type:view", "sys:type:opera"}, logical = Logical.OR)
    @RequestMapping("/typeManagement")
    public String pageTypeManagement() {
        return "pages/typeManagement";
    }


    @RequiresPermissions(value = {"enterprise:group:view", "enterprise:group:poera"}, logical = Logical.OR)
    @RequestMapping("/deviceGroup")
    public String pageDeviceGroup() {
        return "pages/deviceGroup";
    }


}
